﻿
Partial Class WebForm_SearchEnlistHeaderControl
    Inherits System.Web.UI.UserControl

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Me.Visible = False
    End Sub

    Protected Sub gv_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles gv.RowCommand
        If e.CommandName = "Select" Then
            'Dim row As GridViewRow = TryCast(TryCast(e.CommandSource, Control).NamingContainer, GridViewRow)
            'Dim key As DataKey = Me.gv.DataKeys(row.RowIndex)

            Dim rowIndex As Integer = e.CommandArgument

            Me.SelectedEnlistID = Me.gv.DataKeys(rowIndex)("EnlistID")
            RaiseEvent SelectedIndexChanged(Me, New EventArgs)
        End If
    End Sub
End Class

Partial Class WebForm_SearchEnlistHeaderControl
    Public Sub Show()
        Me.BindGV()
        Me.mpSearch.Show()
        Me.Visible = True
    End Sub

    Private Sub BindGV()
        Dim dat As New clsData
        'Dim sql As New MyUserDataFilter
        Dim sql As New MyStringBuilder

        sql.Length = 0
        sql.AppendFormat("select eh.*, o.OrganizationName ")
        sql.AppendFormat(" from EnlistHeader eh ")
        sql.AppendFormat(" inner join OrganizationView o on eh.UOrganizationID = o.UOrganizationID ")

        'sql.AppendFormat(Me.GetWhereSQL())

        Me.gv.DataSource = dat.GetData(sql)
        Me.gv.DataBind()

    End Sub

    Private Function GetWhereSQL() As String
        Dim sql As New MyStringBuilder

        Return sql.ToString()
    End Function

    Public Property SelectedEnlistID() As String
        Get
            Return ViewState("SelectedEnlistID")
        End Get
        Set(ByVal value As String)
            ViewState("SelectedEnlistID") = value
        End Set
    End Property

    Public Event SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs)
End Class